<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<script type="text/javascript"
	src='<c:url value="/resources/js/profit/profitTable.js"/>'></script>
	
<form id="pagingForm">
	<input type="hidden" name="yesterSelledAmount" value="${ yesterSelledAmount }">
	<input type="hidden" name="profitReturnPercent" value="${profitReturnPercent }">
	<input type="hidden" name="profitID" value="${profitID }" id="profitID">
	<input type="hidden" name="pageIndex" id="pageIndexField" value="${pageIndex }">
</form>	
<form id="excelForm" action="<c:url value="/MainMenu/profit/generateChart.htm"/>">
</form>
<form id="excelTableForm" action="<c:url value="/MainMenu/profit/generateProfitReturnTable.htm"/>">
</form>
<table>
	<tr>
		<th>
			<input type="checkbox" id="allChecked">
		</th>
		<th>
			会员卡号
		</th>
		<th>
			会员姓名
		</th>
		<th>
			建卡时间
		</th>
		<th>
			身份证
		</th>
		<th>
			联系电话
		</th>
		<th>
			操作员
		</th>
		<th>
			当天返利金额
		</th>
		<th>
			已返还金额
		</th>
		<th>
			返利目标金额
		</th>
		<th>
			还剩金额
		</th>
	</tr>
	<c:forEach items="${pagingBean.data }" var="profitDetail"
				varStatus="status">
				<c:if test="${status.count%2==0}">
					<tr class="odd">
				</c:if>
				<c:if test="${status.count%2!=0}">
					<tr>
				</c:if>
				<td>
					<input type="checkbox" name="selectMembers" value="${profitDetail.memberID }">
				</td>
				<td>
					<a href="#" onclick="viewReturnHistory(${profitDetail.memberID })">
						${profitDetail.memberCardNumber }
					</a>
				</td>
				<td>
					${profitDetail.memberName }
				</td>
				<td>
					${profitDetail.createDate }
				</td>
				<td>
					${profitDetail.idCardNumber }
				</td>
				<td>
					${profitDetail.phoneNumber }
				</td>
				<td>
					${profitDetail.operatorName }
				</td>
				<td>
					${profitDetail.todayShouldReturnAmount }
				</td>
				<td>
					${profitDetail.returnedAmount }
				</td>
				<td>
					${profitDetail.targetReturnAmount }
				</td>
				<td>
					${profitDetail.remainAmount }
				</td>
				</tr>
			</c:forEach>
	<tr>
		<th colspan="8" class="t-left">
			<input type="button" id="batchEditReturnAmount" value="批量修改返回金额">
			<input type="button" onclick="batchReturnProfit()" value="批量返利金额">
			<input type="button" onclick="genegateChart()" value="生成打款报表">
			<input type="button" onclick="generateExcel()" value="返利表导出到EXCEL">
		</th>
		<th colspan="5" class="t-right">
			<c:if test="${pagingBean.hasPreviousPage }">
				<input id="previousButton" type="button" value="上一页">
				<input id="previousPageIndex" type="hidden" value="${pagingBean.previousPage}">
			</c:if>
			<c:if test="${!pagingBean.hasPreviousPage }">
				<input id="previousButton" type="button" disabled="disabled" value="上一页">
			</c:if>
			<input id="currentPageIndex" type="hidden" value="${pagingBean.afterDeletePage}">
			<select name="pageIndex" id="pageSelection">
				<c:if test="${empty pagingBean.data }">
					<option selected="selected" value="1">
						第1页
					</option>
				</c:if>
				<c:if test="${!empty pagingBean.data }">
					<c:forEach items="${pagingBean.pageIndexList }" var="index">
						<c:if test="${index==pagingBean.currentPage }">
							<option selected="selected" value="${index }">
								第${index }页
							</option>
						</c:if>
						<c:if test="${index!=pagingBean.currentPage }">
							<option value="${index }">
								第${index }页
							</option>
						</c:if>
					</c:forEach>
				</c:if>
			</select>
			<c:if test="${pagingBean.hasNextPage }">
				<input id="nextButton" type="button" value="下一页">
				<input id="nextPageIndex" type="hidden" value="${pagingBean.nextPage}">
			</c:if>
			<c:if test="${!pagingBean.hasNextPage }">
				<input id="nextButton" type="button" disabled="disabled" value="下一页">
			</c:if>
		</th>
	</tr>
</table>


<div id="editAmountDialog" title="请输入新的返还金额">
	<form id="editNewAmountForm">
		<input type="hidden" id="memberIds" name="memberIDs" value="" />
	金额：<input type="text" name="newAmount" id="newAmount"/>
	<input type="button" value="提交" id="submitNewAmountBtn" onclick="editNewAmount()" />
	</form>
</div>